package com.windowes.weichang.component.qiniu;

import com.qiniu.util.Auth;
import com.windowes.weichang.common.ServerResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/***
 *
 * @author: yangqing
 * @email: qing.yang@bangdao-tech.com
 * @createTime: 2018/5/28 下午7:01
 * @description:
 *
 **/
@Component
@Slf4j
public class QiniuHelper {

    @Autowired
    QiniuConfig config;


    public ServerResponse getToken() {
        Auth auth = Auth.create(config.getAccessKey(), config.getSecretKey());
        String upToken = auth.uploadToken(config.getBucket());
        log.info("QiniuHelper.getToken:{}",upToken);
        return ServerResponse.createBySuccess("token获取成功!", upToken);
    }
}
